package com.ymatou.query.trading.api.testcase;

import java.util.ArrayList;
import java.util.Map;

import org.json.JSONArray;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.query.trading.api.parameter.GetOrderListByOrderIdListBean;
import com.ymatou.query.trading.api.service.GetOrderListByOrderIdListCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.utils.constant.ECode;

public class Ts_GetOrderListByOrderIdList {
	private static GetOrderListByOrderIdListBean getorderlistbyorderidlistbean;
	private static GetOrderListByOrderIdListCall getorderlistbyorderidlistcall;
	
	 
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("根据订单id列表获取订单列表");
	}

	@Before
	public void caseUp() {

		getorderlistbyorderidlistbean = new GetOrderListByOrderIdListBean();
		getorderlistbyorderidlistcall = new GetOrderListByOrderIdListCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getorderlistbyorderidlistcall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetOrderListByOrderIdList_001(){
		Logger.start(true,"根据订单id列表获取订单列表成功");
		try {
			// 创建订单
			ArrayList<Integer> list = new ArrayList<Integer>();
			Map info = new OrderCallService().createBatchM2cOrder(3);
			JSONArray Orderlist = (JSONArray) info.get("orderIds");
			int sellerId = (Integer) info.get("sellerId");		
			for (int k = 0; k < Orderlist.length(); k++) {
				list.add(Orderlist.getInt(k));
			}
			
			// 参数
			getorderlistbyorderidlistbean.setOrderIdList(list);
			getorderlistbyorderidlistbean.setSellerId(sellerId);			
			
			// 发送请求
			getorderlistbyorderidlistcall.setData(getorderlistbyorderidlistbean);
			getorderlistbyorderidlistcall.callService();
			Logger.verifyEquals(ECode.SUCCESS,getorderlistbyorderidlistcall.getCode(),"验证code");
		}catch (Exception e) {
			Logger.fail(e);
		    }
	}
	

}
